package myJs.specialMember

import myJs.assets._
import myJs.myPkg.{NavigateOptions, Outlet, ReactRouterDOM}
import myJs.tool.Tool
import myJs.{HeaderCp, assets}
import org.scalajs.dom.window.localStorage
import shared.pojo.Role
import slinky.core.FunctionalComponent
import slinky.core.annotations.react
import slinky.core.facade.Hooks._
import slinky.web.html._

import scala.scalajs.js

/**
 * Created by yz on 22/4/2022
 */
@react object SpecialMemberCp {

  type Props = Unit

  private val css = List(
    assetsCss.Layer,
    assetsCss.Sweetalert,
    assetsCss.BootstrapDatepicker3,
    assetsCss.BootstrapMin,
    assetsCss.BootstrapThemeMin,
    assetsCss.FontAwesomeMin,
    assetsCss.Layout,
    assetsCss.Components,
    assetsCss.Light2,
    assetsCss.UniformDefault,
    assetsCss.BootstrapTable,
    assetsCss.Nprogress,
    assetsCss.TableFilter,
    assetsCss.My,
  )

  val component = FunctionalComponent[Props] { props =>

    val navigate = ReactRouterDOM.useNavigate()

    object FTool {

    }

    useEffect(() => {
      assetsJs.Layout.init()
    }, List()
    )

    useEffect(() => {
      if (Tool.getRoleOp.isEmpty || Tool.getRoleOp.get != Role.SpecialMember) {
        navigate("/", options = NavigateOptions(state = js.Dictionary("message" -> "请先登录！")))
      }
    }
    )

    div(
      div(className := "page-content-wrapper",
        div(className := "page-header-fixed page-quick-sidebar-over-content",
          LeftCp(),
          div(className := "page-container",
            HeaderCp(),
            TagCp(),
            Outlet()
          )
        )
      )
    )


  }

}
